<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/interna.xhtml">

	<ui:define name="nav">
		<h:form id="menu">
			<p:menu id="menuItens" styleClass="menu">
				<p:menuitem value="Cadastro" url="/admin/categoria/cadastro"/>
				<p:menuitem value="Atualiza&ccedil;&atilde;o" url="/admin/categoria/atualizacao"/>
				<p:menuitem value="Ativar categoria" url="/admin/categoria/ativacao"/>
			</p:menu>
		</h:form>
	</ui:define>

	<ui:define name="centro">

		<h2 class="titulo-admin">Cadastro de categorias</h2>

		<p:separator id="separator" styleClass="separador" />

		<h:form id="formCategoria">

			<p:messages id="messages" 
			    showDetail="true" 
			    autoUpdate="true"
				showSummary="false" />

			<div id="box-cat-esq">

				<h:panelGrid columns="2" cellspacing="10">

					<p:commandButton value="Incluir"
						actionListener="#{categoriaManagedBean.incluirNivel1}"
						update="list list2 list3 nome" 
						process="@this, nome" />

					<p:inputText value="#{categoriaManagedBean.categoria.nome}"
						id="nome" 
						required="true"
						requiredMessage="Nome deve ser informado">
						<f:validateLength for="nome" minimum="3" />
					</p:inputText>

					<h:outputLabel value="N&iacute;vel 1" />
					<p:selectOneListbox id="list"
						style="height:250px;
						width:185px;"
						value="#{categoriaManagedBean.categoriaSelecionada}"
						converter="categoriaConverter">
						<f:selectItems value="#{categoriaManagedBean.categorias}"
							var="categoria" 
							itemLabel="#{categoria.nome}"
							itemValue="#{categoria}" />
						<p:ajax update="list2 list3"
							listener="#{categoriaManagedBean.carregarNivel2}" />
					</p:selectOneListbox>

				</h:panelGrid>

			</div>

			<div id="box-cat-dir">
				<h:panelGrid columns="2" cellspacing="10">

					<p:commandButton value="Incluir"
						actionListener="#{categoriaManagedBean.incluirNivel3}"
						update="list3 ssnome" 
						process="@this, ssnome" />

					<p:inputText value="#{categoriaManagedBean.subParente.nome}"
						id="ssnome" 
						required="true"
						requiredMessage="Nome deve ser informado">
						<f:validateLength for="ssnome" minimum="3" />
					</p:inputText>

					<h:outputLabel value="N&iacute;vel 3" />
					<p:selectOneListbox id="list3"
						style="height:250px;
						width:185px;">
						<f:selectItems value="#{categoriaManagedBean.subsParentes}"
							var="subParente" 
							itemLabel="#{subParente.nome}"
							itemValue="#{subParente}" />
					</p:selectOneListbox>
				</h:panelGrid>
			</div>

			<div id="box-cat-centro">
				<h:panelGrid columns="2" cellspacing="10">

					<p:commandButton value="Incluir"
						actionListener="#{categoriaManagedBean.incluirNivel2}"
						update="list2 snome" 
						process="@this, snome, list" />

					<p:inputText value="#{categoriaManagedBean.catParente.nome}"
						id="snome" 
						required="true"
						requiredMessage="Nome deve ser informado">
						<f:validateLength for="snome" minimum="3" />
					</p:inputText>

					<h:outputLabel value="N&iacute;vel 2" />
					<p:selectOneListbox id="list2" 
					    style="height:250px;width:185px;"
						value="#{categoriaManagedBean.catParenteSelecionada}"
						converter="categoriaConverter">
						<f:selectItems value="#{categoriaManagedBean.catsParentes}"
							var="catParente" 
							itemLabel="#{catParente.nome}"
							itemValue="#{catParente}" />
						<p:ajax update="list3"
							listener="#{categoriaManagedBean.carregarNivel3}" />
					</p:selectOneListbox>
				</h:panelGrid>
			</div>
		</h:form>
	</ui:define>
</ui:composition>
</html>